
#pragma once

#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>

#include <opencv2/objdetect.hpp>

#include <iostream>

using namespace cv;

namespace course_08_face_detection
{

    //缩放大小
    void face_detection(std::string imgPath, std::string xmlPath)
    {
        Mat image = imread(imgPath);

        //加载脸型判断文件
        CascadeClassifier faceCascade;
        faceCascade.load(xmlPath);
        if (faceCascade.empty())
        {
            std::cout << "error face_detection_xmlPath" << std::endl;
        }

        //开始判断各尺寸图片的人脸
        std::vector<Rect> faces;
        faceCascade.detectMultiScale(image, faces, 1.1, 10);
        //绘制判断结果框
        for (int i = 0; i < faces.size(); i++)
        {
            rectangle(image, faces[i].tl(), faces[i].br(), Scalar(130.0, 10.0, 150), 3);
        }

        imshow("IMAGE", image);

        waitKey(0);
    }

}